package cn.wwxula.common.model;

import lombok.Data;

/**
 * @author liyang23
 * @date 2024/12/09 17:41
 **/
@Data
public class Result<T> {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 数据对象
     */
    private T data;
    /**
     * 消息
     */
    private String msg;

    public Result() {
        this.code = 200;
        this.msg = "success";
    }

    public Result(Integer code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }
    public static<T> Result<T> success() {
        return new Result<>(200, null, "success");
    }
    public static<T> Result<T> success(T data) {
        return new Result<>(200, data, "success");
    }
    public static<T> Result<T> fail(Integer code, String msg) {
        return new Result<>(code, null, msg);
    }
}
